## Calcular casos possíveis: Cria um .csv com as combinações possíveis para as variáveis
## Copyright (c) 2017, 2018 Adonay Felipe Nogueira <https://libreplanet.org/wiki/User:Adfeno>

## This program is free software: you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation, version 3 of the
## License.

## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.

## You should have received a copy of the GNU General Public License
## along with this program.  If not, see
## <https://www.gnu.org/licenses/>.

args <- commandArgs(trailingOnly = TRUE)
arquivo_de_saida_csv <- args[1]

## Cria as dimensões com três categorias.
dimensoes <- lapply(1:14,
                    function(x) {
                        c(0, NA, 1)})

## Insere as dimensões com duas categorias.
dimensoes <- append(dimensoes,
                    list(0:1),
                    4)

## Define os nomes das dimensões, conforme as alíneas mencionadas na
## metodologia proposta..
names(dimensoes) <- letters[1:length(dimensoes)]

## Escreve os casos possíveis em um arquivo CSV.
write.csv(expand.grid(dimensoes),
          file = arquivo_de_saida_csv,
          na = "",
          row.names = FALSE)
